<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2023-02-09 19:30:26
 * @Last Modified time: 2023-02-18 13:56:28
 */
namespace app\common\services\store;

use think\facade\Db;
use frank\base\BaseService;
use frank\exception\CommonException;
use app\common\dao\store\OrderGoodsDao;
use app\common\services\store\GoodsSkuService;

/**
 * 订单商品
 * Class OrderGoodsService
 */
class OrderGoodsService extends BaseService
{
    /**
     * OrderGoodsService constructor.
     * @param UserAddressDao $dao
     */
    public function __construct(OrderGoodsDao $dao)
    {
        $this->dao = $dao;
    }

    public function getOrderGoodsDetail($filter){
        $detail = $this->dao->search($filter)->find();
        if (!$detail) {
            throw new CommonException('商品不存在');
        }
        return $detail->toArray();
    }

    /**
     * 获取未评价的商品
     */
    public function getNotCommentGoodsList($orderId)
    {
        $data = $this->dao->search([
            'order_id' => $orderId,
            'comment_status' => 0
        ])->select();
        return  $data;
    }
}
